# -*- coding: utf-8 -*-
from fixture import user
from api.base_api.base_api import BaseApi
from api.base_api.register import RegisterApi
from api.base_api import settings
import requests

class LoginBaseApi(BaseApi):
    login_url = "http://192.168.1.141:8001/login"


    def login_base_api(self, mobile, password):
        # 登录
        captcha_hash = RegisterApi().get_user_captcha_hash()
        captcha_code = user.get_response(captcha_hash)
        payload = {
            "mobile": mobile,
            "captcha_hash": captcha_hash,
            "captcha_code": captcha_code,
            "password": password
        }
        response = self.post(self.login_url, payload)
        token = response.json()['token']
        settings.HEADERS["token"] = token
        hander = settings.HEADERS
        return hander




